package com.itheima.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletDemo06 extends HttpServlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        //活了
        System.out.println("demo06创建了");
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uri = req.getRequestURI();
        StringBuffer url= req.getRequestURL();
        System.out.println(uri);
        System.out.println(url);
        if(uri.endsWith("add.do")){
            System.out.println("新增了一个 xxx");
        }else if(uri.endsWith("delete.do")) {
            System.out.println("删除干活了");
        }else if(uri.endsWith("update.do")) {
            System.out.println("更新干活了");
        }else if(uri.endsWith("find.do")) {
            System.out.println("查看干活了");
        }else {
            System.out.println("我也不知道你要干啥");
        }



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
